<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>基本使用</title>
  </head>
  <body>
    <script>
      const canvas = document.createElement("canvas");
      canvas.width = 400;
      canvas.height = 400;
      document.body.append(canvas);

      const ctx = canvas.getContext("2d");
      const img = new Image();
      img.src =
        "https://img.chuapp.com//wp-content/Picture/2017-03-08/58bfb93d25c08.jpg?imageView2/5/w/587/h/330";
      img.onload = function () {
        ctx.drawImage(img, 0, 0, 100, 100, 100, 100, 100, 100);
      };
    </script>
  </body>
</html>
